import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:osg/controllers/http.dart';

class EntrustSuccess extends StatefulWidget {
   EntrustSuccess({super.key});

  @override
  State<EntrustSuccess> createState() => _WebDetailState();
}

class _WebDetailState extends State<EntrustSuccess> {
    final id = Get.parameters['id'];
    final back = Get.parameters['back'];
    
     RxMap info = {}.obs;
getInfo()
{
   Get.find<HTTPS>().getData('/order/check', {
    "order_id":'$id'
    }).then((res){
    if(res!=null){
       info.value = res;
    }
    });
}

 @override
  void initState() {
    super.initState();
     WidgetsBinding.instance.addPostFrameCallback((_) {
      getInfo();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          Align(
            child: Column(
              children: [
                SizedBox(
                  height: 50,
                ),
                Image.asset(
                  'static/web/success.png',
                  width: 75,
                  fit: BoxFit.fitWidth,
                ),
                SizedBox(
                  height: 15,
                ),
                Obx(()=>
                info['pay']==true?
                  Text(
                 '支付成功',
                  style: TextStyle(fontSize: 15, color: Color(0XFF0F172B)),
                ):Text(
                 '支付失败',
                  style: TextStyle(fontSize: 15, color: Color(0XFF0F172B)),
                )
                )
                ,
                
                SizedBox(
            height: 20,
          ),
              ],
            ),
          ),
          Container(
            padding: EdgeInsets.all(15),
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10),
                color: Color(0XFFF8F9FD)),
            margin: EdgeInsets.symmetric(horizontal: 15),
            child: Column(
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      '藏品名称',
                      style: TextStyle(fontSize: 14, color: Color(0XFF999999)),
                    ),
                    Obx(()=>
                    Text(
                      '${info['title']}',
                      style: TextStyle(fontSize: 14, color: Color(0XFF0F172B)),
                    )
                    )
                    ,
                  ],
                ),
                SizedBox(
                  height: 20,
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      '委托价格',
                      style: TextStyle(fontSize: 14, color: Color(0XFF999999)),
                    ),
                    Obx(()=>
                    Text(
                      '${info['pay_money_price']}',
                      style: TextStyle(fontSize: 14, color: Color(0XFF0F172B)),
                    )
                    )
                    ,
                  ],
                ),
                SizedBox(
                  height: 20,
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      '委托数量',
                      style: TextStyle(fontSize: 14, color: Color(0XFF999999)),
                    ),
                    Obx(()=>
                    Text(
                      '${info['total']}',
                      style: TextStyle(fontSize: 14, color: Color(0XFF0F172B)),
                    )
                    )
                    ,
                  ],
                ),
                
              ],
            ),
          ),
          SizedBox(
            height: 50,
          ),
          GestureDetector(
            onTap: (){
              Get.offNamed('/');
            },
            child: Container(
            margin: EdgeInsets.symmetric(horizontal: 15),
            height: 50,
            alignment: Alignment.center,
            decoration: BoxDecoration(
              color: Color(0XFF0F172B),
              borderRadius: BorderRadius.circular(50),
            ),
            child: Text(
              '确认',
              style: TextStyle(color: Color(0XFFFFFFFF), fontSize: 18),
            ),
          ),
          )
          
        ],
      ),
    );
  }
}
